package com.xoa.controller.knowledge;

import com.xoa.model.knowledge.KnowledgeDocfile;
import com.xoa.service.knowledge.FileManageService;
import com.xoa.util.LimsJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author: ZhuYize
 * @Date: 2020/9/12 15:59
 * @Description: 文档管理控制器
 */
@Controller
@RequestMapping("/fileManage")
public class FileManageController {

    @Autowired
    private FileManageService fileManageService;


    @RequestMapping("/getFileManagePage")
    public String getFileManagePage() { return "/app/knowledge/fileManager/fileManage"; }

    @RequestMapping("/getFilSerchPage")
    public String getFilSerchPage() { return "/app/knowledge/fileManager/fileSerch"; }


    /**
     *
     * @作者 李卫卫
     * @创建日期 12:20 2020/9/14
     * @类介绍 编辑文档
     * @参数
     * @return limsJson
     */
    @RequestMapping("/updateBySelective")
    @ResponseBody
    public LimsJson updateBySelective(KnowledgeDocfile record) {
        return fileManageService.updateBySelective(record);
    }


    /**
     *
     * @作者 李卫卫
     * @创建日期 12:41 2020/9/14
     * @类介绍  查看文档
     * @参数
     * @return limsJson
     */
    @RequestMapping("/selectByDocfileId")
    @ResponseBody
    public LimsJson selectByDocfileId(Integer docfileId) {
        return fileManageService.selectByDocfileId(docfileId);
    }


    /**
     * @Author: ZhuYize
     * @Date: 2020/9/14 19:21
     * @Description: 获取栏目类型下的文档
     * @param: columnIds
     * @param: page 页数
     * @param: limit 每页条数
     * @return: LimsJson
     */
    @RequestMapping("/getFile")
    @ResponseBody
    public LimsJson getFile(String columnIds, Integer page, Integer limit) {

        return fileManageService.getFiles(columnIds, page, limit);
    }


    /**
     * @Author: ZhuYize
     * @Date: 2020/9/15 15:17
     * @Description: 删除文档
     * @param: delFile 文档id串
     * @return: LimsJson
     */
    @RequestMapping("/delFile")
    @ResponseBody
    public LimsJson delFile(String columnIds) {

        return fileManageService.deleteFile(columnIds);
    }


    /**
     * @Author: ZhuYize
     * @Date: 2020/9/15 16:16
     * @Description: 新增文档
     * @param: request 请求数据
     * @param: knowledgeDocfile 添加的数据
     * @return: LimsJson
     */
    @RequestMapping("/insertFile")
    @ResponseBody
    public LimsJson insertFile(HttpServletRequest request, KnowledgeDocfile knowledgeDocfile) {

        return fileManageService.insertFile(request, knowledgeDocfile);
    }


    @RequestMapping("/serchFile")
    @ResponseBody
    public LimsJson serchFile(HttpServletRequest request, KnowledgeDocfile knowledgeDocfile,Integer page,Integer limit) {

        return fileManageService.serchFile(request, knowledgeDocfile,page,limit);
    }

    @RequestMapping("/generStr")
    @ResponseBody
    public LimsJson generStr(HttpServletRequest request) {
        return fileManageService.generStr(request);
    }
}